<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%--
	auth : Conner
	date : 2012-09-05
	desc : 权限列表
--%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/admin/common/css/style_sub.jsp"></jsp:include>
<script type="text/javascript" src="<%=basePath%>js/lib/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/public.js"></script>
<script language="javascript">
//更新权限状态
function updateRightState(rightId, status){
	var params = {
			ct : getCurrentTime(),
			'right.id' : rightId,
			'right.r_status' : status
	};
	$.getJSON('<%=basePath%>basic/sys/right_updateRightStatus.action', params, function(json){
		if(json.resultCode == 'success'){
			alert("改变权限状态成功！");
			$('#searchBtn').click();
		}else{
			alert("改变权限状态失败，请联系管理员！");
		}
	});
}

//点击行看明细
function goDetail(id){
	document.location.href = "<%=basePath%>basic/sys/right_queryByRid.action?right.id=" + id + "&type=detail";
}


//编辑
function edit(url){
	document.location.href = url;
}
</script>
</head>
<body>
	<form action="<%=basePath%>basic/sys/right_selectRight.action" id="sf" method="post">
		<div class="searchTab">
			<table>
				<tr>
					<th>菜单名称</th>
					<td>
						<input type="text" name="right.name" value="${right.name}"/>
					</td>
					<th>所属子系统</th>
					<td>
						<select name="right.sub_id">
							<option value="0">===请选择===</option>
							<s:iterator value="%{listSubSystem}">
								<option value="${id }">${name }</option>
							</s:iterator>
						</select>
					</td>
				</tr>
				<tr>
					<th>当前状态</th>
					<td>
						<label><input type="radio" name="right.r_status" value="1" <s:if test="%{right.r_status == 1}">checked="checked"</s:if>/>
						<img src="<%=basePath%>style/icons/ok.png" title="启用" alt="启用" align="absmiddle"/></label>&nbsp;&nbsp;&nbsp;&nbsp;
						<label><input type="radio" name="right.r_status" value="2" <s:if test="%{right.r_status == 2}">checked="checked"</s:if>/>
						<img src="<%=basePath%>style/icons/pause.png" title="禁用" alt="禁用" align="absmiddle"/></label>
					</td>
					<th>&nbsp;</th>
					<td>
						<span class="btn"><input type="submit" id="searchBtn" value="查询"/></span>
						<span class="btn">
							<input type="button" value="添加权限" 
								onclick="javascript:window.location.href = '<%=basePath%>basic/sys/right_findAllRightSubSys.action'"/>
						</span>
						<span class="btn"><input type="button" value="删除所选" onclick="javascript:del('<%=basePath%>basic/sys/right_delete.action');"/></span>
					</td>
				</tr>
			</table>
		</div>
		<!--查询条件表格-->
		<div class="listTab">
			<table>
				<thead>
					<tr>
						<td><a href="javascript:void(0);" onclick="javascript:selectAll();">全选</a></td>
						<td>层级</td>
						<td>菜单名称</td>
						<td>所属子系统</td>
						<td>同级排序号</td>
						<td>限制访问</td>
						<td>是否控制子资源权限</td>
						<td>外部访问</td>
						<td>叶子节点</td>
						<td>类型</td>
						<td>当前状态</td>
						<td>操作</td>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="%{pm.list}" id="right">
					<tr>
						<td><input type="checkbox" name="chk" value="${id}" id="${id}" /></td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细" align="left">
							<s:if test="#right.level_ == 1">根菜单</s:if>
							<s:elseif test="#right.level_ == 2">一级功能</s:elseif>
							<s:elseif test="#right.level_ == 3">二级功能</s:elseif>
							<s:elseif test="#right.level_ == 4">三级功能</s:elseif>
							<s:elseif test="#right.level_ == 5">四级功能</s:elseif>
						</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细" align="left">${name }</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细" align="left">${sub_name }</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细" align="left">${order_ }</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细">
							<s:if test="#right.limit_access == 1">是</s:if>
							<s:elseif test="#right.limit_access == 2">否</s:elseif>
						</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细">
							<s:if test="#right.filter_subres == 1">是</s:if>
							<s:elseif test="#right.filter_subres == 2">否</s:elseif>
						</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细">
							<s:if test="#right.external_access == 1">允许</s:if>
							<s:elseif test="#right.external_access == 2">不允许</s:elseif>
						</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细">
							<s:if test="#right.is_leaf == 1">是</s:if>
							<s:elseif test="#right.is_leaf == 2">否</s:elseif>
						</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细">
							<s:if test="#right.r_type == 1">菜单</s:if>
							<s:elseif test="#right.r_type == 2">按钮</s:elseif>
						</td>
						<td onclick="javascript:goDetail(${id});" style="cursor:pointer;" title="点击行看明细">
							<s:if test="#right.r_status == 1">
								<img src="<%=basePath%>style/icons/ok.png" title="启用" alt="启用"/>
							</s:if>
							<s:elseif test="#right.r_status == 2">
								<img src="<%=basePath%>style/icons/pause.png" title="禁用" alt="禁用"/>
							</s:elseif>
						</td>
						<td>
							<a href="javascript:void(0);" class="modi" onclick="edit('<%=basePath%>basic/sys/right_queryByRid.action?right.id=${id}&type=edit');">编辑</a>
							<a href="javascript:void(0);" class="return" onclick="deleteById(${id}, '<%=basePath%>basic/sys/right_delete.action');">删除</a>
							<s:if test="#right.r_status == 1">
								<a href="javascript:void(0);" class="disc" onclick="updateRightState(${id}, 2);">禁用</a>
							</s:if>
							<s:else>
								<a href="javascript:void(0);" class="enable" onclick="updateRightState(${id}, 1);">启用</a>
							</s:else>
						</td>
					</tr>
					</s:iterator>
					<s:if test="%{pm.list.size() == 0}">
					<tr>
						<td colspan="12"><font>暂时没有内容信息</font></td>
					</tr>
					</s:if>
				</tbody>
			</table>
		</div>
		<s:if test="%{pm.list.size() > 0}">
		<jsp:include page="/admin/common/pagemodel.jsp"></jsp:include>
		</s:if>
	</form>
</body>
</html>
